The present invention relates generally to the rendering of graphical elements into raster pixel images and, in particular, to the efficient rendering of such elements to pixel image data using alpha-channel compositing. The invention also relates to a computer program product including a computer readable medium having recorded thereon a computer program for the efficient rendering of graphical elements to pixel image data using alpha-channel compositing.
Computer generated images are typically made up of many differing components or graphical elements which are rendered and composited together to create a final image. In recent times, xe2x80x9calpha valuesxe2x80x9d have been used in order to assist in the rendering of images. The colour associated with each element in an image is given an alpha value representing the contribution of the element to a final pixel value. An element with an alpha value of zero is typically understood to be fully transparent and an element with an alpha value of one is typically understood to be fully opaque. The alpha value is typically stored alongside each instance of a colour. Therefore, along with the RGB (Red, Green, Blue) values of a pixel, there is an alpha value representing the coverage of the pixel. The collection of all of the alpha values for an image is often called an xe2x80x9calpha channelxe2x80x9d (also known as a xe2x80x9cmattexe2x80x9d, an xe2x80x9copacity channelxe2x80x9d, or simply xe2x80x9copacityxe2x80x9d).
The combining of source colour and opacity with destination colour and opacity will now be described with reference to FIG. 1. As seen in FIG. 1, when a source pixel 100 and destination pixel 101 are composited together, the pixels 100, 101 are conceptually overlaid, so that they anti-correlate to give four regions (i.e. three non-transparent regions 103, 105, 107 and one transparent region 111) in the combined resultant pixel 109. The three non-transparent regions 103, 105 and 107, can be defined as SOUTD (ie. source outside destination), SROPD (i.e. source intersect destination) and DOUTS (i.e. destination outside source), respectively. The colour value of each of these three regions is calculated conceptually independently. The source outside destination region 103 takes it""s colour directly from the source colour. The destination outside source region takes it""s colour directly from the destination colour. The source intersect destination region 105 takes it""s colour from a combination of the source and destination colour. Each of the three regions 103, 105 and 107 contributes a proportion of it""s colour to the final colour of a resultant pixel according to the opacity value of that particular region. The opacity contribution from each of the three regions 103, 105, 107 can be defined as below, where xcex1 represents the opacity value between 0 and 1 for the xe2x80x98srcxe2x80x99 (i.e. source) and xe2x80x98destxe2x80x99 (i.e. destination) pixel:
SOUTD=xcex1src(1xe2x88x92xcex1dest);xe2x80x83xe2x80x83(1)
DOUTS=xcex1dest(1xe2x88x92xcex1src); andxe2x80x83xe2x80x83(2)
SROPD=xcex1srcxcex1dest.xe2x80x83xe2x80x83(3)
The process of combining source and destination colour is termed a raster operation and is one of a set of functions specified by raster operation code used in conjunction with many alpha-compositing systems employed by computer graphics systems. The alpha value, xcex1, for a particular pixel is typically represented as an 8 bit word in the range 0 to 255, representing the range between zero and one (i.e. normalised). As a result, the product of the multiplication of the source and destination pixels has to be xe2x80x98range correctedxe2x80x99 (i.e. divided by 255) to return to an 8-bit word representing the range between 0 and 1 for the resultant pixel.
FIG. 2 is a schematic diagram of a prior art alpha-compositing module 200 employed by a computer graphics system in order to combine source colour and opacity with destination colour and opacity. The module 200 comprises an opacity combination system 202 and a colour combination system 205. The opacity combination system 202 and the colour combination system 205 calculate the resultant pixel opacity and colour values, respectively. The Csrc, Cdest and Cresult operands represent the colour of the source, destination and resultant (i.e. xe2x80x98resultxe2x80x99) pixels, respectively. The xcex1src, xcex1dest and xcex1result operands represent the opacity value of the source, destination and resultant (i.e. xe2x80x98resultxe2x80x99) pixels, respectively. The contributions from the three regions, SOUTD, SROPD and DOUTS due to the compositing of the source and destination pixels, are controlled by three opacity flags, USE_SOUTD, USE_SROPD, and USE_DOUTS, respectively. If the flag for a region is set, there is some contribution from that region, otherwise, the contribution from that particular region is zero.
The module 200 of FIG. 2 uses an 8-bit word to represent the alpha value for a particular pixel. Therefore, the opacity contribution from each region has to be range corrected by being divided by the number 255, using dividers 210, 220 and 230. The resultant opacity is calculated by summing the three range corrected opacity values for the three regions SOUTD, SROPD and DOUTS, using a summer 201. The resultant colour Cresult is divided by the resultant opacity, using a divider 240. As conceptually seen from FIG. 2, there is a long processing path from the initial colour and opacity operands to the resultant colour and opacity and typically the destination operand is taken from a compositing stack which contains the result of a previous operation. Therefore, it is not possible to pipeline such an operation and simplifying the data path while maintaining the precision is very important.
It is an object of the present invention to substantially overcome, or at least ameliorate, one or more disadvantages of existing arrangements.
According to one aspect of the present invention there is provided an apparatus for compositing first and second pixel values, said apparatus comprising:
logic means for calculating combined range uncorrected colour and opacity values using opacity and colour values for each of said first and second pixel values;
selection means for selecting a reciprocal range uncorrected opacity value from a plurality of predetermined reciprocal range uncorrected opacity values using said combined range uncorrected opacity value;
multiplier means for multiplying said reciprocal range uncorrected opacity value with said combined range uncorrected colour value to determine a final range corrected resultant colour value for a third pixel; and
divider means for dividing said combined range uncorrected opacity value by a predetermined number wherein said divider means is configured to calculate a final range corrected resultant opacity value for said third pixel.
According to another aspect of the present invention there is provided apparatus for compositing first and second pixel values, said apparatus comprising:
a plurality of inputs for receiving opacity and colour values for each of said first and second pixels;
logic means for calculating combined range uncorrected colour and opacity values using said opacity and colour values;
selection means for selecting a reciprocal range uncorrected opacity value from a plurality of predetermined reciprocal range uncorrected opacity values using said combined opacity value;
multiplier means for multiplying said reciprocal range uncorrected opacity value with said combined range uncorrected colour value to produce a final range corrected resultant colour value for a third pixel; and
divider means for dividing said range uncorrected combined opacity value by a predetermined number, wherein said divider means is configured to calculate a final range corrected resultant opacity value for said third pixel.
According to still another aspect of the present invention there is provided a method of compositing first and second pixel values, said comprising the steps of:
inputting opacity and colour values for each of said first and second pixels;
calculating combined range uncorrected colour and opacity values using said opacity and colour values;
selecting a range uncorrected reciprocal opacity value from a plurality of predetermined range uncorrected reciprocal opacity values using said combined range uncorrected opacity value;
multiplying said range uncorrected reciprocal opacity value with said combined range uncorrected colour value to produce a final resultant range corrected colour value for a third pixel; and
dividing said combined range uncorrected opacity value by a predetermined number to produce a final resultant range corrected opacity value for said third pixel, wherein said final resultant range corrected opacity value for said third pixel is determined subsequent to said combined range uncorrected opacity value being calculated.
According to still another aspect of the present invention there is provided a computer readable medium, having a program recorded thereon, where the program is configured to make a computer execute a procedure to composite first and second pixel values, said program comprising:
code for inputting opacity and colour values for each of said first and second pixels;
code for calculating combined range uncorrected colour and opacity values using said opacity and colour values;
code for selecting a range uncorrected reciprocal opacity value from a plurality of predetermined range uncorrected reciprocal opacity values using said combined range uncorrected opacity value;
code for multiplying said range uncorrected reciprocal opacity value with said combined range uncorrected colour value to produce a final resultant range corrected colour value for a third pixel; and
code for dividing said combined range uncorrected opacity value by a predetermined number to produce a final resultant range corrected opacity value for said third pixel, wherein said final resultant range corrected opacity value for said third pixel is determined subsequent to said combined range uncorrected opacity value being calculated.